﻿<template>
  <div class="app-container">
    <div class="filter-title">
      <el-form label-position="right" label-width="95px">
        <el-form-item :label="$t('order.no')+' :'">
          <el-input
            v-model="listQuery.order_no"
            style="width: 150px"
            class="filter-item"
            :placeholder="$t('order.no')"
            @keyup.enter.native="handleFilter"
          ></el-input>
        </el-form-item>
        <el-form-item :label="$t('order.buyerType')+' :'">
          <el-select
            v-model="listQuery.buyer_type"
            clearable
            style="width: 150px"
            class="filter-item"
            :placeholder="$t('order.buyerType')"
          >
            <el-option
              v-for="item in typeOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('order.productName')+' :'">
          <el-input
            v-model="listQuery.goods_name"
            style="width: 150px"
            class="filter-item"
            :placeholder="$t('order.productName')"
            @keyup.enter.native="handleFilter"
          ></el-input>
        </el-form-item>
        <el-button
          style="margin-left:20px"
          class="filter-item"
          type="primary"
          icon="el-icon-search"
          @click="handleFilter"
        >{{ $t('table.search') }}</el-button>
        <el-button
          style="margin-left: 10px"
          class="filter-item"
          type="primary"
          @click="handleRefresh"
        >{{ $t('table.refresh') }}</el-button>
        <div v-show="!showSearchItem" class="showDown" @click="showSearchItem = true">
          <i class="el-icon-d-arrow-right"></i>
        </div>
        <div v-show="showSearchItem" class="showUp" @click="showSearchItem = false">
          <i class="el-icon-d-arrow-left"></i>
        </div>
      </el-form>
    </div>
    <div v-show="showSearchItem" class="filter-container">
      <el-form label-position="right" label-width="95px">
        <el-form-item :label="$t('order.status')+' :'">
          <el-select
            v-model="listQuery.order_status"
            clearable
            style="width: 150px"
            class="filter-item"
            :placeholder="$t('order.status')"
          >
            <el-option
              v-for="item in orderStatusOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('order.createTime')+' :'">
          <div class="filter-item">
            <el-date-picker
              v-model="listQuery.startTime"
              :picker-options="pickerOptionsB"
              type="date"
              :placeholder="$t('public.startTime')"
              value-format="yyyy-MM-dd HH:mm:ss"
            ></el-date-picker>
          </div>
          <div class="filter-item">
            <el-date-picker
              v-model="listQuery.endTime"
              :picker-options="pickerOptionsE"
              type="date"
              :placeholder="$t('order.endTime')"
              value-format="yyyy-MM-dd HH:mm:ss"
            ></el-date-picker>
          </div>
        </el-form-item>
      </el-form>
    </div>
    <el-table
      :key="tableKey"
      v-loading="listLoading"
      :data="list"
      element-loading-text="拼命加载中"
      element-loading-spinner="el-icon-loading"
      element-loading-background="rgba(255,255,255,0.2)"
      border
      fit
      highlight-current-row
      style="width: 100%min-height:1000px"
    >
      <el-table-column fixed="left" align="center" :label="$t('table.id')" width="65">
        <template slot-scope="scope">
          <span>{{ (listQuery.page-1)*listQuery.limit+scope.$index+1 }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip :label="$t('order.no')">
        <template slot-scope="scope">
          <span>{{ scope.row.order_no }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip :label="$t('order.buyer')">
        <template slot-scope="scope">
          <span>{{ scope.row.username }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip :label="$t('goods.name')">
        <template slot-scope="scope">
          <span>{{ scope.row.goods_name }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('goods.picture')" width="150px">
        <template slot-scope="scope">
          <img
            width="100%"
            height="auto"
            :src="scope.row.goods_picture"
            :alt="scope.row.goods_name"
          />
        </template>
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip :label="$t('order.money')">
        <template slot-scope="scope">
          <span>{{ scope.row.order_money }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip :label="$t('order.adCurrency')">
        <template slot-scope="scope">
          <span>{{ scope.row.ad_currency }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip :label="$t('order.extraCurrency')">
        <template slot-scope="scope">
          <span>{{ scope.row.extra_currency }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip :label="$t('order.createTime')">
        <template slot-scope="scope">
          <span>{{ scope.row.create_time }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('order.status')">
        <template slot-scope="scope">
          <span>{{ rechargeEs(scope.row.order_status) }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('order.checkStatus')">
        <template slot-scope="scope">
          <span
            :class="statusColorSecond(scope.row.check_status)"
          >{{ statusEstimation(scope.row.check_status) }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('order.checkStatus2')">
        <template slot-scope="scope">
          <span
            :class="statusColorSecond(scope.row.check_status2)"
          >{{ statusEstimation(scope.row.check_status2) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        align="center"
        :label="$t('table.actions')"
        :width="operWidth"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            type="primary"
            size="mini"
            @click="handleRead(scope.row)"
          >{{ $t('table.read') }}</el-button>
          <el-button
            v-if="permission.firstCheck"
            type="primary"
            size="mini"
            :disabled="scope.row.check_status === 1 || scope.row.check_status === 3?false:true"
            @click="handleManagerReview(scope.row)"
          >{{ $t('table.managerReview') }}</el-button>
          <el-button
            v-if="permission.thirdlyCheck"
            type="primary"
            size="mini"
            :disabled="scope.row.check_status2 === 1 || scope.row.check_status2 === 3 ?false:true"
            @click="handleWarehouseReview(scope.row)"
          >{{ $t('table.warehouseReview') }}</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination-container">
      <el-pagination
        background
        :current-page="listQuery.page"
        :page-sizes="[10,20,30,50]"
        :page-size="listQuery.limit"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      ></el-pagination>
    </div>
    <!-- 编辑 -->
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
      <el-form
        ref="dataForm"
        style="width: 400px margin-left:120px"
        label-position="right"
        label-width="35%"
        size="small"
        :rules="rules"
        :model="temp"
      >
        <el-form-item :label="$t('order.no')+' :'">
          <span>{{ temp.order_no }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.type')+' :'">
          <span>{{ withdrawES(temp.order_type) }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.buyer')+' :'">
          <span>{{ temp.username }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.buyerType')+' :'">
          <span>{{ buyerTypeEs(temp.buyer_type) }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.productName')+' :'">
          <span>{{ temp.goods_name }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.picture')+' :'">
          <span>{{ temp.picture }}</span>
          <img :src="temp.goods_picture" width="100px" height="auto" />
        </el-form-item>
        <el-form-item :label="$t('order.marketPrice')+' :'">
          <span>{{ temp.market_price }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.price')+' :'">
          <span>{{ temp.price }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.productNum')+' :'">
          <span>{{ temp.num }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.goodsMoney')+' :'">
          <span>{{ temp.goods_money }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.money')+' :'">
          <span>{{ temp.order_money }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.adCurrency')+' :'">
          <span>{{ temp.ad_currency }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.extraCurrency')+' :'">
          <span>{{ temp.extra_currency }}</span>
        </el-form-item>
        <el-form-item :label="$t('public.region')+' :'">
          <span>{{ temp.region_name }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.createTime')+' :'">
          <span>{{ temp.create_time }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.status')+' :'">
          <span>{{ statusEstimation(temp.order_status) }}</span>
        </el-form-item>
        <el-form-item
          v-if="dialogStatus==='managerReview'"
          :label="$t('order.checkStatus')+' :'"
          prop="check_status"
        >
          <el-radio-group v-model="temp.check_status">
            <el-radio :label="1" disabled>审核中</el-radio>
            <el-radio :label="2">审核通过</el-radio>
            <el-radio :label="3">未通过</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item
          v-if="dialogStatus==='warehouseReview'"
          :label="$t('order.checkStatus2')+' :'"
          prop="check_status2"
        >
          <el-radio-group v-model="temp.check_status2">
            <el-radio :label="1" disabled>审核中</el-radio>
            <el-radio :label="2">审核通过</el-radio>
            <el-radio :label="3">未通过</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item
          v-if="temp.check_status === 3 && dialogStatus==='managerReview'"
          :label="$t('public.auditOpinion')+' :'"
          prop="check_remark"
        >
          <el-input v-model="temp.check_remark" type="textarea"></el-input>
        </el-form-item>
        <el-form-item
          v-if="temp.check_status2 === 3 && dialogStatus==='warehouseReview'"
          :label="$t('public.auditOpinion')+' :'"
          prop="check_remark2"
        >
          <el-input v-model="temp.check_remark2" type="textarea"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">{{ $t('table.cancel') }}</el-button>
        <el-button
          v-if="dialogStatus==='managerReview'"
          type="primary"
          :disabled="!createDisabled"
          @click="managerReviewData"
        >{{ $t('table.confirm') }}</el-button>
        <el-button
          v-if="dialogStatus==='warehouseReview'"
          type="primary"
          :disabled="!createDisabled"
          @click="warehouseReviewData"
        >{{ $t('table.confirm') }}</el-button>
      </div>
    </el-dialog>

    <!-- 查看 -->
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormRead">
      <el-form
        :model="temp"
        label-position="right"
        label-width="40%"
        style="width: 400px margin-left:120px"
      >
        <el-form-item :label="$t('order.no')+' :'">
          <span>{{ temp.order_no }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.type')+' :'">
          <span>{{ withdrawES(temp.order_type) }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.buyer')+' :'">
          <span>{{ temp.username }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.buyerType')+' :'">
          <span>{{ buyerTypeEs(temp.buyer_type) }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.productName')+' :'">
          <span>{{ temp.goods_name }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.picture')+' :'">
          <span>{{ temp.picture }}</span>
          <img :src="temp.goods_picture" width="100px" height="auto" />
        </el-form-item>
        <el-form-item :label="$t('order.marketPrice')+' :'">
          <span>{{ temp.market_price }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.price')+' :'">
          <span>{{ temp.price }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.productNum')+' :'">
          <span>{{ temp.num }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.goodsMoney')+' :'">
          <span>{{ temp.goods_money }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.money')+' :'">
          <span>{{ temp.order_money }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.adCurrency')+' :'">
          <span>{{ temp.ad_currency }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.extraCurrency')+' :'">
          <span>{{ temp.extra_currency }}</span>
        </el-form-item>
        <el-form-item :label="$t('public.region')+' :'">
          <span>{{ temp.region_name }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.createTime')+' :'">
          <span>{{ temp.create_time }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.status')+' :'">
          <span>{{ rechargeEs(temp.order_status) }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.checkStatus')+' :'">
          <span>{{ statusEstimation(temp.check_status) }}</span>
        </el-form-item>
        <el-form-item :label="$t('order.checkStatus2')+' :'">
          <span>{{ statusEstimation(temp.check_status2) }}</span>
        </el-form-item>
        <el-form-item v-if="temp.check_status === 3" :label="$t('order.checkRemark')+' :'">
          <span>{{ temp.check_remark }}</span>
        </el-form-item>
        <el-form-item v-if="temp.check_status2 === 3" :label="$t('order.checkRemark2')+' :'">
          <span>{{ temp.check_remark2 }}</span>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
import { getToken } from "@/utils/auth"; // get token from cookie

export default {
  name: "OrderList",
  data() {
    const remark = (rule, value, callback) => {
      if (value) {
        if (value.length <= 0) {
          callback(new Error("请输入审核意见"));
        } else if (value.length > 300) {
          callback(new Error("审核意见不能超过300个字符"));
        } else {
          callback();
        }
      } else {
        callback(new Error("请输入审核意见"));
      }
    };
    const remark2 = (rule, value, callback) => {
      if (value) {
        if (value.length <= 0) {
          callback(new Error("请输入审核意见"));
        } else if (value.length > 300) {
          callback(new Error("审核意见不能超过300个字符"));
        } else {
          callback();
        }
      } else {
        callback(new Error("请输入审核意见"));
      }
    };
    return {
      showSearchItem: false,
      tableKey: 0,
      list: null,
      total: null,
      listLoading: true,
      type: "",
      typeOptions: [
        {
          value: 1,
          label: "运营中心"
        },
        {
          value: 2,
          label: "广告主"
        },
        {
          value: 3,
          label: "商家"
        }
      ],
      orderStatusOptions: [
        {
          value: 1,
          label: "审核中"
        },
        {
          value: 2,
          label: "审核通过"
        },
        {
          value: 3,
          label: "未通过"
        },
        {
          value: 4,
          label: "交易成功"
        }
      ],
      listQuery: {
        page: 1,
        limit: 20,
        order_no: "",
        buyer_type: "",
        goods_name: "",
        order_status: "",
        startTime: "",
        endTime: ""
      },
      temp: {
        id: undefined,
        check_status: "",
        check_remark: ""
      },
      temptime: [{ start: "", end: "" }],
      dialogFormVisible: false,
      dialogFormRead: false,
      dialogStatus: "",
      upLoading: false,
      visibleVideo: false,
      textMap: {
        update: "更新",
        create: "添加",
        review: "审核",
        read: "查看",
        managerReview: "审核",
        warehouseReview: "审核"
      },
      rules: {
        check_status: [
          { required: true, message: "请审核", trigger: "change" }
        ],
        check_remark: [{ required: true, trigger: "blur", validator: remark }],
        check_status2: [
          { required: true, message: "请审核", trigger: "change" }
        ],
        check_remark2: [{ required: true, trigger: "blur", validator: remark2 }]
      },
      createDisabled: true,
      updateDisabled: true,
      loading: false,
      industryOptions: [],
      areaOptions: [],
      areaCount: undefined,
      videoOptions: [],
      videoCount: undefined,
      industryCount: undefined,
      pageSize: 20,
      equipmentOptions: [],
      equipmentCount: undefined,
      permission: {
        firstCheck: false,
        thirdlyCheck: false
      },
      pickerOptionsB: {
        // 限制时间
        // selectableRange: ['22:00:00 - 23:59:59','00:00:00 - 02:00:00'],
        // 限制日期
        disabledDate: this.disabledDateB
      },
      pickerOptionsE: {
        disabledDate: this.disabledDateE
      },
      pickerOptionsBT: {
        disabledDate: this.disabledDateBT
      },
      pickerOptionsET: {
        disabledDate: this.disabledDateET
      }
    };
  },
  computed: {
    operWidth: function() {
      let itemCount = 1;
      if (this.permission.firstCheck) {
        itemCount += 1;
      }
      if (this.permission.thirdlyCheck) {
        itemCount += 1;
      }
      return itemCount * 80 + 40 + "px";
    }
  },
  created() {
    if (this.$store.state.permission.jurisdiction === "*") {
      this.permission.firstCheck = true;
      this.permission.thirdlyCheck = true;
    } else {
      const jurisdiction = this.$store.state.permission.jurisdiction.split(",");
      jurisdiction.forEach(element => {
        const id = parseInt(element);
        if (id === 215) {
          this.permission.firstCheck = true;
        } else if (id === 216) {
          this.permission.thirdlyCheck = true;
        }
      });
    }
    this.type = JSON.parse(getToken()).type;
    this.getList();
  },
  methods: {
    disabledDateB(time) {
      let times = time.getTime() > Date.now();
      if (this.listQuery.endTime) {
        times =
          time.getTime() > Date.now() ||
          time.getTime() >
            new Date(this.listQuery.endTime).getTime() +
              24 * 3600 * 1000 -
              8.64e7;
      }
      return times;
    },
    disabledDateE(time) {
      let times = time.getTime() > Date.now();
      if (this.listQuery.startTime) {
        times =
          time.getTime() > Date.now() ||
          time.getTime() <
            new Date(this.listQuery.startTime).getTime() - 8.64e6;
      }
      return times;
    },
    disabledDateBT(time) {
      if (this.temp.end_time) {
        return (
          time.getTime() >
          new Date(this.temp.end_time).getTime() + 24 * 3600 * 1000 - 8.64e7
        );
      }
    },
    disabledDateET(time) {
      if (this.temp.start_time) {
        return (
          time.getTime() < new Date(this.temp.start_time).getTime() - 8.64e6
        );
      }
    },
    getList() {
      this.listLoading = true;
      const data = {
        rows: this.listQuery.limit,
        page: this.listQuery.page
      };
      if (this.listQuery.order_no) {
        data["order_no"] = this.listQuery.order_no;
      }
      if (this.listQuery.buyer_type) {
        data["buyer_type"] = this.listQuery.buyer_type;
      }
      if (this.listQuery.goods_name) {
        data["goods_name"] = this.listQuery.goods_name;
      }
      if (this.listQuery.order_status) {
        data["order_status"] = this.listQuery.order_status;
      }
      if (this.listQuery.startTime) {
        data["startTime"] = this.listQuery.startTime;
      }
      if (this.listQuery.endTime) {
        const date = new Date(this.listQuery.endTime);
        data["endTime"] = this.timestampToTime(
          date.getTime() + (60 * 60 * 24 * 1000 - 1)
        );
      }

      const orderListPath = {
        // 获取规则列表
        company: "STQ",
        api: "pc_order_orderList",
        version: "1.0",
        data: data
      };

      this.socketApi.sendSock(JSON.stringify(orderListPath), res => {
        if (res) {
          this.socketData(res);
          this.listLoading = false;
        } else {
          this.$message.error(" 获取订单列表失败 ");
          this.listLoading = false;
        }
      });
    },
    timeFormat(time) {
      const date = new Date(time);
      const Y = date.getFullYear();
      const M =
        date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1;
      const D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
      return Y + "." + M + "." + D;
    },
    handleFilter() {
      this.listQuery.page = 1;
      this.getList();
    },
    handleSizeChange(val) {
      this.listQuery.limit = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.listQuery.page = val;
      this.getList();
    },
    handleRefresh() {
      this.listQuery = {
        page: 1,
        limit: 20,
        name: "",
        status: "",
        play_status: "",
        regions_name: "",
        trade_name: "",
        startTime: "",
        endTime: ""
      };
      this.getList();
    },
    handleReview(row) {
      // 打开审核弹窗
      this.temp = Object.assign({}, row); // copy obj
      this.dialogStatus = "review";
      this.dialogFormVisible = true;
      this.$nextTick(() => {
        this.$refs["dataForm"].clearValidate();
      });
    },
    handleManagerReview(row) {
      // 打开经理审核
      this.temp = Object.assign({}, row); // copy obj
      this.dialogStatus = "managerReview";
      this.dialogFormVisible = true;
      this.$nextTick(() => {
        this.$refs["dataForm"].clearValidate();
      });
    },
    handleWarehouseReview(row) {
      // 打开仓库审核
      this.temp = Object.assign({}, row); // copy obj
      this.dialogStatus = "warehouseReview";
      this.dialogFormVisible = true;
      this.$nextTick(() => {
        this.$refs["dataForm"].clearValidate();
      });
    },
    handleRead(row) {
      // 打开查看弹窗
      this.temp = Object.assign({}, row); // copy obj
      this.dialogStatus = "read";
      this.dialogFormRead = true;
    },
    managerReviewData() {
      // 出入库信息审核(经理)
      this.$refs["dataForm"].validate(valid => {
        if (valid) {
          if (this.updateDisabled) {
            this.updateDisabled = false;
            const data = {
              order_id: this.temp.order_id,
              check_status: this.temp.check_status
            };
            if (this.temp.check_remark) {
              data["check_remark"] = this.temp.check_remark;
            }
            const thirdlyCheckPath = {
              company: "STQ",
              api: "pc_order_firstCheck",
              version: "1.0",
              data: data
            };
            this.socketApi.sendSock(JSON.stringify(thirdlyCheckPath), res => {
              if (res) {
                this.socketData(res);
              } else {
                this.$message.error(" 审核失败 ");
              }
              setTimeout(() => {
                this.updateDisabled = true;
              }, 1000);
            });
          }
        }
      });
    },
    warehouseReviewData() {
      // 出入库信息审核(仓库)
      this.$refs["dataForm"].validate(valid => {
        if (valid) {
          if (this.updateDisabled) {
            this.updateDisabled = false;
            const data = {
              order_id: this.temp.order_id,
              check_status: this.temp.check_status
            };
            if (this.temp.check_remark) {
              data["check_remark2"] = this.temp.check_remark;
            }
            const firstCheckPath = {
              company: "STQ",
              api: "pc_order_thirdlyCheck",
              version: "1.0",
              data: data
            };
            this.socketApi.sendSock(JSON.stringify(firstCheckPath), res => {
              if (res) {
                this.socketData(res);
              } else {
                this.$message.error(" 审核失败 ");
              }
              setTimeout(() => {
                this.updateDisabled = true;
              }, 1000);
            });
          }
        }
      });
    },
    // 区域行业选择
    getIndustry(pageNumber, search) {
      const industryIndexPath = {
        company: "STQ",
        api: "pc_trade_index",
        version: "1.0",
        data: {
          name: search,
          page: pageNumber,
          rows: this.pageSize,
          type: 2
        }
      };
      this.socketApi.sendSock(JSON.stringify(industryIndexPath), res => {
        if (res) {
          this.socketData(res);
        }
      });
    },
    getArea(pageNumber, search) {
      const areaIndexPath = {
        company: "STQ",
        api: "pc_region_index",
        version: "1.0",
        data: {
          name: search,
          page: pageNumber,
          rows: this.pageSize
        }
      };
      this.socketApi.sendSock(JSON.stringify(areaIndexPath), res => {
        if (res) {
          this.socketData(res);
        }
      });
    },
    // 视频源名查询
    getvideoName(pageNumber, search) {
      const adVideoGetNamePath = {
        company: "STQ",
        api: "pc_AdVideo_getName",
        version: "1.0",
        data: {
          name: search,
          page: pageNumber,
          rows: this.pageSize
        }
      };
      this.socketApi.sendSock(JSON.stringify(adVideoGetNamePath), res => {
        if (res) {
          this.socketData(res);
        }
      });
    },
    getEquipment(pageNumber, search) {
      const getEquipmentCodePath = {
        company: "STQ",
        api: "pc_equipment_getEquipmentCode",
        version: "1.0",
        data: {
          name: search,
          page: pageNumber,
          rows: this.pageSize
        }
      };
      this.socketApi.sendSock(JSON.stringify(getEquipmentCodePath), res => {
        if (res) {
          this.socketData(res);
        }
      });
    },
    socketData(res) {
      if (res !== '{"type":"ping"}') {
        const resj = JSON.parse(res);
        if (resj.code === -1) {
          this.$message.error(resj.message);
        } else {
          if (resj.api === "pc_order_orderList") {
            // 充值列表
            this.total = resj.count;
            this.list = resj.data;
          } else if (resj.api === "pc_order_firstCheck") {
            // 出入库审核(仓库)
            this.dialogFormVisible = false;
            this.getList();
            this.$notify({
              title: "成功",
              message: "审核成功",
              type: "success",
              duration: 2000
            });
          } else if (resj.api === "pc_order_thirdlyCheck") {
            // 出入库审核(经理)
            this.dialogFormVisible = false;
            this.getList();
            this.$notify({
              title: "成功",
              message: "审核成功",
              type: "success",
              duration: 2000
            });
          }
        }
      }
    }
  }
};
</script>
